//
//  BotLineTextField.m
//  DogeLegs
//
//  Created by 宋华 on 2017/9/8.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "BotLineTextField.h"

@interface BotLineTextField () {

}

@property (nonatomic,strong)CALayer *botLayer;

@end

@implementation BotLineTextField

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self defaultConfig];

    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self defaultConfig];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self resetBotFrame];
}

- (void)resetBotFrame {
    float height=self.frame.size.height + 5;
    float width=self.frame.size.width;
    _botLayer.frame = CGRectMake(0.0f, height, width, 1.0f);
}

- (void)defaultConfig {
    self.botColor = HEXCOLOR(0x999999);
    self.clipsToBounds = NO;
    self.borderStyle = UITextBorderStyleNone;
}

- (void)setBotColor:(UIColor *)botColor {
    if (_botColor != botColor) {
        _botColor = botColor;
        self.botLayer.backgroundColor = _botColor.CGColor;
    }
}

#pragma mark - getter 
- (CALayer *)botLayer {
    if (_botLayer == nil) {
        _botLayer = [CALayer layer];
        [self resetBotFrame];
        _botLayer.backgroundColor = HEXCOLOR(0x999999).CGColor;
        
        [self.layer addSublayer:_botLayer];
    }
    return _botLayer;
}

@end
